<template>
	<!-- orderlist商铺铺订单列表 -->
	<view class="o_wp">
		<view class="o_nav">
			<view class="o_nav_item" :class="{active:tabIndex==4}" @click="tabClick(4)">全部</view>
			<view class="o_nav_item" :class="{active:tabIndex==1}" @click="tabClick(1)">待发货</view>
			<view class="o_nav_item" :class="{active:tabIndex==2}" @click="tabClick(2)">待收货</view>
			<view class="o_nav_item" :class="{active:tabIndex==3}" @click="tabClick(3)">已完成</view>
		</view>
		<view class="o_list">
			<view class="o_item" v-for="(item,index) in list" :key="index">
				<view class="o_ordersn">
					<text>订单号：<text selectable>{{item.ordersn}}</text></text>
					<text class="o_status">{{item.statusName}}</text>
				</view>
				<view class="shop_list">
					<view class="s_item" v-for="(iitem,iindex) in item.goodsList" :key="iindex">
						<image :src="iitem.thumb" mode=""></image>
						<view class="s_info">
							<view class="s_title">{{iitem.goodstitle}}</view>
							<view class="s_total_guige">
								<text>数量：{{iitem.total}}</text>
								<text v-if="iitem.optionname">规格：{{iitem.optionname}}</text>
							</view>
							<view>￥{{iitem.realprice}}</view>
						</view>
					</view>
					<view class="s_message">
						共<text>{{item.goodsList.length}}</text>件商品&nbsp;&nbsp;实付款<text>￥</text><text>{{item.price}}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="loading_message">
			<image v-if="isloading" src="../../static/business/loading.gif"></image>
			<view v-if="isempty">到底了~</view>
		</view>
		<bot-tomtab></bot-tomtab>
	</view>
</template>

<script>
	import BotTomtab from '@/components/bottomtab.vue';
	export default {
		components: {
			BotTomtab
		},
		data() {
			return {
				uid: '',

				tabIndex: 4,

				list: [],
				page: 0,


				isloading: false,
				isempty: false,
			}
		},
		onReachBottom() {
			this.getlist();
		},
		onLoad(option) {
			this.uid = option.uid;
			this.getlist();
		},
		methods: {
			getlist(e) {
				this.page += 1;
				this.isloading = true;
				this.$axios('groupManager/sendOrder', 'POST', 'supplier', {
					page: this.page,
					uid: this.uid,
					status: this.tabIndex
				}).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						let length = res.data.data.list.length;
						this.list = this.list.concat(res.data.data.list);
						this.isempty = length <= 0 ? true : false;
					}
				})
			},
			tabClick(e) {
				if (e == this.tabIndex) return;
				this.tabIndex = e;
				this.list = [];
				this.page = 0;
				this.isempty = false;
				this.getlist();
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f2f2f2;
		color: $font-color-dark;
		padding-bottom: 130upx;
	}

	.o_nav {
		background-color: #fff;
		display: flex;
		align-items: center;
		position: fixed;
		left: 0;
		width: 100%;
		z-index: 100;
	}

	.o_nav_item {
		flex: 1;
		text-align: center;
		line-height: 80upx;
		position: relative;
	}

	.active {
		color: $base-color;
	}

	.active:after {
		content: '';
		border-bottom: 2px $base-color solid;
		position: absolute;
		bottom: 0;
		left: 50%;
		transform: translateX(-50%);
		width: 40upx;
	}

	.o_list {
		overflow: hidden;
		padding-top: 80upx;
	}

	.o_item {
		background-color: #fff;
		padding: 0 20upx;
		margin-top: 20upx;
	}

	.o_ordersn {
		line-height: 70upx;
		border-bottom: 1px hsl(0, 0%, 87%) solid;
	}

	.o_status {
		color: $base-color;
		float: right;
	}

	.shop_list {
		padding: 20upx 0;
	}

	.s_item {
		display: flex;
		padding-bottom: 20upx;
	}

	.s_item image {
		border-radius: 10upx;
		height: 120upx;
		width: 120upx;
	}

	.s_info {
		padding-left: 20upx;
		width: calc(100% - 120upx);
		line-height: 40upx;
	}

	.s_title {
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
		width: 100%;
	}

	.s_total_guige,
	.s_message {
		font-size: $font-sm;
		color: $font-color-light;
	}

	.s_total_guige text {
		margin-right: 30upx;
	}

	.s_message {
		text-align: right;
	}

	.s_message text {
		color: $font-color-dark;
	}

	.s_message text:nth-of-type(1) {
		margin: 0 10upx;
	}

	.s_message text:nth-of-type(2) {
		font-size: 22upx;
		margin-left: 10upx;
	}

	.s_message text:nth-of-type(3) {
		font-size: $font-lg;
	}

	.loading_message {
		padding: 40upx;
		color: #0062CC;
		text-align: center;
	}

	.loading_message image {
		height: 50upx;
		width: 50upx;
	}
</style>
